/***********************************************************************
 * Module:  DAODataConnection.java
 * Author:  Alexandro
 * Purpose: Defines the Class DAODataConnection
 ***********************************************************************/

package dao;

import java.util.*;
import java.sql.*;

public class DAODataConnection {
   private static String stringConnection;
   public static int maxRows = 10;
   /** @param query */
   public static ResultSet executerQuery(String query) throws java.sql.SQLException {
   	try{
   	
      		Class.forName("com.mysql.jdbc.Driver");			
			Connection conexion = DriverManager.getConnection(stringConnection);			
			Statement instruccion = conexion.createStatement();									
			ResultSet tabla = instruccion.executeQuery(query);								
			return tabla;
		}
	catch(ClassNotFoundException e){ System.out.println(e); }		
		return null;
   }
   
   public static int executer(String query) throws java.sql.SQLException {
   	try{
   	
      		Class.forName("com.mysql.jdbc.Driver");			
			Connection conexion = DriverManager.getConnection(stringConnection);			
			Statement instruccion = conexion.createStatement();									
			boolean result = instruccion.execute(query);								
			return 0;
		}
	catch(ClassNotFoundException e){ System.out.println(e); }		
		return 1;
   }
   
   public static String getStringConnection() {
      return stringConnection;
   }
   
   /** @param newStringConnection */
   public static void setStringConnection(String newStringConnection) {
      stringConnection = newStringConnection;
   }

}